<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>


<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="${ctx}/css/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>
<script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
<script type="text/javascript">
    /*$(document).ready(function() {
        $('#example').dataTable({
            "sPaginationType": "full_numbers"
        });
    });*/
</script>
<!-- DATATABLES CSS END -->

<h1 class="page-title">职务设置 - ${duty == null ? "添加" : "修改"}</h1>

<div class="container_12 clearfix leading">

    <%@ include file="/WEB-INF/pages/common/common_tree.jsp"%>

    <div class="side grid_8 leading">
        <form class="form has-validation" id="post_form" name="post_form" method="post">
            <div class="clear"></div>
            <div class="clearfix">
                <label for="dutyName" class="form-label">职务名称 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="dutyName" name="duty.dutyName" required="required" placeholder="请输入职务名称" value="${duty.dutyName}"/>
                </div>
            </div>

            <div class="clearfix">
                <label for="dutyContent" class="form-label">职务描述 <em>*</em></label>
                <div class="form-input">
                    <textarea id="dutyContent" name="duty.dutyContent" required="required" rows="5" placeholder="请输入职务描述">${duty.dutyContent}</textarea>
                </div>
            </div>

            <div class="clearfix">
                <div class="clearfix">
                    <div class="form-input">
                        <input type="hidden" id="default_organization_id" name="duty.organization.id">
                        <input type="hidden" name="duty.id" value="${duty.id}">
                    </div>
                </div>
            </div>

            
            <div class="form-action clearfix">
                <button class="button" type="button" onclick="checkForm()">${duty == null ? "添加" : "修改"}</button>
                <button class="button" type="button" onclick="resetForm()">重置</button>
                <a class="button" href="#rank/duty.xhtml">
                    <span style="background:url(${ctx}/images/img/arrow_undo.png)" class="icon">&nbsp;</span>返回
                </a>
            </div>

        </form>
    </div>
</div>

<div class="clear"></div>


<script type="text/javascript" src="${ctx}/js/Tree.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
    function checkForm(){
        if(checkNull($("#dutyName").attr("value"))){
            alert("职务名称不为空");
            return false;
        }
        if(checkNull($("#dutyContent").attr("value"))){
            alert("职务描述不为空");
            return false;
        }

        var url = "${ctx}/rank/duty_create.xhtml";
        $.ajax(url, {
            type: "POST",
            data: $("#post_form").serialize(),
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url)
            },
            complete:function() {}
        });
    }
    function resetForm(){
        $("#dutyName").attr("value", "");
        $("#dutyContent").attr("value", "");
    }
</script>

    